import query from './atom/db/query';
import count from './atom/db/count';

declare const action_id: string;
declare const session_id: string;
declare const spaceid: string;

interface Message {
	criteria: object,
	page_size: number,
	page_no: number,
	asc: string[],
	desc: string[]
}

async function atom(msg: Message) {
	const systemid = '5991';
	const q = query(action_id, session_id, spaceid, systemid);
	q.prepare('class_room', ['_id', 'classroom_id', 'teaching_building', 'belong_area', 'floor_no', 'house_number', 'classroom_type', 'seat_num',
		'max_intake_capacity', 'fzno', 'campus_id', 'campus_name', 'is_exam_room'], msg.criteria, msg.page_size, msg.page_no, msg.asc, msg.desc);
	const t = await q.exec();
	const c = count(action_id, session_id, spaceid, systemid);
	c.prepare('class_room', msg.criteria);
	const tc = await c.exec();
	return { t: t[0], c: tc[0] };
}
